<?php
/**
 * User: Hufeng
 * Date: 2017/6/12 11:35
 * Desc: 数据Model基类
 */
namespace App\Common\Util;

class Qrcode{

    //生成普通二维码
    public function build($str,$fileName){
        $fileDir = STATIC_FILE_DIR.$fileName.'.png';
        $qrCode = new \Endroid\QrCode\QrCode($str);
        $qrCode->setSize(600);
        $qrCode->setWriterByName('png')
            ->setMargin(10)
            ->setEncoding('UTF-8')
            ->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0])
            ->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255])
            ->setValidateResult(false);
        $qrCode->writeFile($fileDir);
        return $fileDir;
    }
}
